package com.example.kwokg.meishi;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by kwokg on 2016/9/10.
 */
public class MyVpAdapter extends FragmentPagerAdapter {

        private List<Fragment> mData;
        private List<String > mTitles;
        public MyVpAdapter(FragmentManager fm, List<Fragment> list,List<String> titles) {
            super(fm);
            this.mData=list;
            mTitles=titles;
        }

        @Override
        public Fragment getItem(int position) {
            return mData==null?null:mData.get(position);
        }

        @Override
        public int getCount() {
            return mData==null?0:mData.size();
        }

    //根据传进来的List返回标题
    @Override
    public CharSequence getPageTitle(int position) {

        return mTitles.get(position);
    }
}
